package com.lwz.repair.Exception;

import java.io.FileNotFoundException;
import java.io.IOException;

public class Exceptionthrows {

    public static void main(String[] args) throws IOException {
        String filename ="C://a.tx";

        readfile(filename);

    }
//    ileNotFoundException 和IOException为父子关系只需写IOException即可
    public static void readfile(String filename) throws IOException {
//        if (!filename.equals("c://a.txt")){
//            throw new FileNotFoundException("文件路径不正确");
//        }
//        文件后缀不正确
        if (!filename.endsWith(".txt")){
            throw new IOException("文件后缀不正确");
        }



        System.out.println("路径没问题");

    }


}
